﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class StageInfo
{
	/// <summary>
	/// 스테이지 이름
	/// </summary>
	public string	stageName;

	/// <summary>
	/// 아이콘 경로
	/// </summary>
	public string	iconPath;

	/// <summary>
	/// 카메라 추적 타입
	/// </summary>
	public GameCamera.FollowingMode camFollowingMode	= GameCamera.FollowingMode.MapChunk;

	/// <summary>
	/// 월드 정보
	/// </summary>
	public WorldInfo	worldInfo;
}

public class WorldInfo
{
	public class CharInfo
	{
		public Vector2	position;
		public string	prefabPath;

		public int		appearanceClearCount	= 0;

		public CharInfo(Vector2 position, string path, int clearCount = 0)
		{
			Init(position, path, clearCount);
		}

		public CharInfo(int mapChunk, Vector3 localpos, string path, int clearCount = 0)
		{
			Vector3 actualPos		= localpos;
			actualPos.x				+= mapChunk * World.c_mapChunkWidth;

			Init(actualPos, path, clearCount);
		}

		void Init(Vector2 position, string path, int clearCount)
		{
			this.position			= position;
			prefabPath				= path;
			appearanceClearCount	= clearCount;
		}
	}

	// Members


	/// <summary>
	/// 월드 이벤트를 수용할 리시버 오브젝트 프리팹 경로
	/// </summary>
	public string				worldEventReceiverPath;

	public BgmData				worldBgm	= null;

	protected List<string>		m_mapChunkPaths	= new List<string>();
	protected List<CharInfo>	m_charInfos		= new List<CharInfo>();

	public virtual string[] mapChunkPaths
	{
		get
		{
			return m_mapChunkPaths.ToArray();
		}
	}

	public virtual CharInfo[] charInfos
	{
		get
		{
			return m_charInfos.ToArray();
		}
	}


	/// <summary>
	/// 맵 조각 경로 추가
	/// </summary>
	/// <param name="path">Path.</param>
	public void AddMapChunkPath(string path)
	{
		m_mapChunkPaths.Add(path);
	}

	/// <summary>
	/// 캐릭터 배치정보 추가
	/// </summary>
	/// <param name="info">Info.</param>
	public void AddCharInfo(CharInfo info)
	{
		m_charInfos.Add(info);
	}

	/// <summary>
	/// 캐릭터 배치정보 추가
	/// </summary>
	/// <param name="path">Path.</param>
	/// <param name="x">The x coordinate.</param>
	/// <param name="y">The y coordinate.</param>
	/// <param name="clearCount">등장하기 시작할 클리어 횟수</param>
	public void AddCharInfo(string path, float x, float y, int clearCount = 0)
	{
		AddCharInfo(new CharInfo(new Vector2(x, y), path, clearCount));
	}

	/// <summary>
	/// 캐릭터 배치정보 추가
	/// </summary>
	/// <param name="path">Path.</param>
	/// <param name="x">The x coordinate.</param>
	/// <param name="y">The y coordinate.</param>
	/// <param name="clearCount">등장하기 시작할 클리어 횟수</param>
	public void AddCharInfo(int mapChunk, string path, float x, float y, int clearCount = 0)
	{
		AddCharInfo(new CharInfo(mapChunk, new Vector2(x, y), path, clearCount));
	}
}